package cn.elves.model.activity.service.stateflow;

import cn.elves.model.activity.entity.constant.ActivityStateConstants;
import cn.elves.model.activity.service.stateflow.updater.*;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@Component
public class StateHandlerSelector {

    @Resource
    private ArraignmentStateUpdater arraignmentStateUpdater;
    @Resource
    private CloseStateUpdater closeStateUpdater;
    @Resource
    private DoingStateUpdater doingStateUpdater;
    @Resource
    private EditingStateUpdater editingStateUpdater;
    @Resource
    private OpenStateUpdater openStateUpdater;
    @Resource
    private PassStateUpdater passStateUpdater;
    @Resource
    private RefuseStateUpdater refuseStateUpdater;

    public Map<Integer, AbstractStateUpdater> stateGroup = new ConcurrentHashMap<>();

    @PostConstruct
    public void init() {
        stateGroup.put(ActivityStateConstants.EDIT, editingStateUpdater);
        stateGroup.put(ActivityStateConstants.ARRAIGNMENT, arraignmentStateUpdater);
        stateGroup.put(ActivityStateConstants.PASS, passStateUpdater);
        stateGroup.put(ActivityStateConstants.DOING, doingStateUpdater);
        stateGroup.put(ActivityStateConstants.REFUSE, refuseStateUpdater);
        stateGroup.put(ActivityStateConstants.CLOSE, closeStateUpdater);
        stateGroup.put(ActivityStateConstants.OPEN, openStateUpdater);
    }
}
